<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .l-leave {
            margin-left: 0;
            opacity: 1;
        }
        .l-leave-active {
            transition: all 1s;
        }
        .l-leave-to {
            margin-left: 500px;
            opacity: 0;
        }
        .l-enter {
            margin-left: -500px;
            opacity: 0;
        }
        .l-enter-active {
            transition: all 1s;
        }
        .l-enter-to {
            margin-left: 0;
            opacity: 1;
        }
    </style>
</head>
<body>
    <div id="box" style="margin: auto;width: 200px;height: 200px;text-align: center;">
        <button @click="type=!type">切换</button>
        <transition name="l">
            <div style="width: 200px;height: 200px;background-color: rgb(92, 173, 205);" v-show="type"></div>
        </transition>
    </div>
</body>
<script src="./vue.js"></script>
<script>
    new Vue({
        el:"#box",
        data:{
            type:true
        }
    })
</script>
</html>